//
//  main.m
//  Shapes-Procedural
//
//  Created by quentin on 15/8/19.
//  Copyright (c) 2015年 QuentinLabs. All rights reserved.
//

#import <Foundation/Foundation.h>

typedef enum {
    KCircle,
    KRectangle,
    kEgg,
} ShapeType;


typedef enum {
    KRedColor,
    KGreenColor,
    KBlueColor,
} ShapeColor;


typedef struct {
    int x,y,width,height;
}ShapeRect;


typedef struct {
    ShapeType type;
    ShapeColor fillColor;
    ShapeRect bounds;
}Shape;

NSString* colorName(ShapeColor colorName){
    switch (colorName) {
        case KRedColor:
            return @"red";
            
        case KGreenColor:
            return @"green";
            
        case KBlueColor:
            return @"Blue";
            
    }
    return @"no clue";
    
}

void drawCircle(ShapeRect bounds,ShapeColor fillColor){
    NSLog(@"drawing a circle at (%d,%d,%d,%d) in %@",bounds.x,
          bounds.y,bounds.width,bounds.height,
          colorName(fillColor));
}

void drawRectangle(ShapeRect bounds,ShapeColor fillColor){
    NSLog(@"drawing a Rectangle at (%d,%d,%d,%d) in %@",bounds.x,
          bounds.y,bounds.width,bounds.height,
          colorName(fillColor));
}

void drawEgg(ShapeRect bounds,ShapeColor fillColor){
    NSLog(@"drawing a Egg at (%d,%d,%d,%d) in %@",bounds.x,
          bounds.y,bounds.width,bounds.height,
          colorName(fillColor));
}

void drawShapes(Shape shapes[],int count ){

    for (int i = 0; i < count; i++) {
        switch (shapes[i].type) {
            case KCircle:
                drawCircle(shapes[i].bounds,shapes[i].fillColor);
                break;
            case KRectangle:
                drawRectangle(shapes[i].bounds,shapes[i].fillColor);
                break;
            case kEgg:
                drawEgg(shapes[i].bounds,shapes[i].fillColor);
                break;
            default:
                break;
        }
    }
}


int main(int argc, const char * argv[]) {

    Shape shapes[3];
    ShapeRect rect0 = {0,0,10,30};
    shapes[0].type = KCircle;
    shapes[0].fillColor = KRedColor;
    shapes[0].bounds = rect0;
    
    ShapeRect rect1 = {30,40,50,60};
    shapes[1].type = KRectangle;
    shapes[1].fillColor = KGreenColor;
    shapes[1].bounds = rect1;
    
    ShapeRect rect2 = {15,18,37,29};
    shapes[2].type = kEgg;
    shapes[2].fillColor = KBlueColor;
    shapes[2].bounds = rect2;
    
    drawShapes(shapes,3);
    
    return 0;
}
